package a.jframe;

import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.util.Map;
import java.util.Set;

import javax.swing.DefaultListModel;
import javax.swing.JFrame;
import javax.swing.JList;
import javax.swing.JScrollPane;
import javax.swing.JTextField;

import Files.File_;

public class BASEFRAME extends JFrame {

	/*public static BASEFRAME instance=new BASEFRAME();
	public static BASEFRAME get(){
		if (instance==null){
			return instance=new BASEFRAME();
		}
		else
			return instance;
	}*/
	int jframe;
	static JTextField 
		fieldWithCommandName=new JTextField(),
		fieldWithSyntaxOfCommand=new JTextField();

	static JList listbox=new JList();
	
	static 
		DefaultListModel listModel;
	
	JScrollPane scrollPane;
	
	public static void c(int g){
		Map<String,String> c= new File_().readF(g);
		if (!c.isEmpty()){
		Set<String> test = c.keySet();
		listModel.clear();
		for (String key : test) {
			listModel.addElement(c.get(key));
		    }
		}
	}
	void list_(){
		listModel = new DefaultListModel();
		scrollPane = new JScrollPane();
		fillListModel();
		listbox.setModel(listModel);	scrollPane.setViewportView(listbox);
	}
	void fillListModel(){
		Map<String,String> c= new File_().readF(jframe);
		if (!c.isEmpty()){
			listModel.clear();
		Set<String> test = c.keySet();
		for (String key : test) {
			listModel.addElement(c.get(key));
		    }
		}
		
	}
	void zamykanie(){
		  windowAdapter = new WindowAdapter()
	        {
	            public void windowClosing(WindowEvent we)
	            {
	            	System.out.println("aaaa");
	                setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
	            }
	        };

	        addWindowListener(windowAdapter);
	}
	private WindowAdapter windowAdapter;
	
	
}
